package com.joezj.servletdemo.simpledemo;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.Serializable;

/**
 * @Author: JoeZj
 * @Description: 自己创建一个类，实现Servlet接口，处理请求
 * @Date: create in 2020/9/6 16:58
 */
public class MySimpleServlet implements Servlet {

    /**
     * 当前servlet信息（全路径名）
     */
    private static final String SERVLET_NAME = "com.joezj.servletdemo.simpledemo.MySimpleServlet";

    /**
     * 在Servlet初始化时调用
     * @param servletConfig
     * @throws ServletException
     */
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {

    }

    /**
     * 获取ServletConfig配置
     * @return
     */
    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    /**
     * 当Servlet被访问时调用，用来实现业务逻辑
     * @param servletRequest
     * @param servletResponse
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        HttpServletRequest request = (HttpServletRequest)servletRequest;
        final String name = request.getParameter("name");
        // String nameParam =
        // PrintWriter


    }

    /**
     * 获取ServletInfo —— 关于Servlet的信息
     * @return
     */
    @Override
    public String getServletInfo() {
        return null;
    }

    /**
     * Servlet销毁时执行方法
     */
    @Override
    public void destroy() {

    }
}
